<?php


namespace App\Extensions\Exporters;


use Encore\Admin\Grid;
use Encore\Admin\Grid\Exporters\ExcelExporter;
use Maatwebsite\Excel\Concerns\WithMapping;

class PatentTransactionExporter extends ExcelExporter implements WithMapping
{
    protected $fileName = '已转化专利.xlsx';

    protected $columns = [
        'patent_sn' => '专利号',
        'patent_name' => '专利名称',
        'buyer' => '受让方',
        'contact_person' => '联系人',
        'contact_mobile' => '联系电话',
        'amount' => '转化金额（万）',
        'type' => '转化类型',
        'date' => '转化日期',
    ];

    public function __construct(Grid $grid = null)
    {
        parent::__construct($grid);
    }

    public function map($row): array
    {
        return [
            $row->patent_sn . "\t",
            $row->patent_name,
            $row->buyer,
            $row->contact_person,
            $row->contact_mobile . "\t",
            $row->amount,
            $row->type,
            $row->date,
        ];
    }

}
